<template>
  <div>
    <table class="commentdetail-body">
      <tr>
        <td>
          <div v-if="piclength>1" class="commenturl clearfix">
            <img v-for="(item,index) in picarray" v-lazy="item.src+'/thumbnail/!220x170r/gravity/Center/crop/220x170'" class="previewer-demo-img preview-img-item commentimg img-list" :key="index"   @click="saveimgtolocal(picarray,index)">
          </div>

          <div class="onecommenturl" v-if="picarray!=null&&picarray[0]!=null&&piclength==1">
            <img v-for="(item,index) in picarray" v-lazy="item.src+'/thumbnail/!358x277r/gravity/Center/crop/358x277'" class="previewer-demo-img preview-img-item onecommentimg " width="3.58rem" height="2.77rem" :key="index"  @click="saveimgtolocal(picarray,index)">
          </div>
        </td>
        <div v-if="commenttype==null" class="commentdetail-text" @click="reply($event,topicindex,commentindex,tabId)">
          <span class="detailcom" style="color: #111111;" v-html="commenttext">{{commenttext}}</span>
        </div>
        <div v-else-if="commenttype!=null" class="commentdetail-text" @click="reply($event,topicindex,commentindex,tabId)">
          <span class="detailcom" style="color: #111111;" >回复
            <span style="color: #fb685b;"> @ {{atname}} </span>: {{commenttext}}</span>
            <span class="detailcom" v-html="commenttext"></span>
        </div>
        <span v-if="isdisplacetype==2" class="displace-explain" v-html="description">
          {{description}}
        </span>
      <div class="position-place">
        <span class="yl-2map" style="font-size: 0.26rem;"></span>
        <span>{{repplace}}</span>
      </div>
      </tr>
    </table>
    <div class="body-sep"></div>
  </div>
</template>
<script>
import { mapState, mapMutations } from "vuex"
export default {
  data() {
    return {
      showImg: false,
      imgShow: false,
      comment: '',
      beforeOrientImg: [],
      imgstr:[],//点击跳转幸福绿城app
    }
  },
  computed: {
    ...mapState([
      'isShow'
    ])
  },
  props: ['commenttext', 'piclength', 'imgurl', 'picarray', 'isdisplacetype', 'commenttype', 'commentindex', 'topicindex', 'atname', 'description', 'i', 'tabId','repplace'],
  methods: {
    ...mapMutations([
      'changeShow'
    ]),
    reply(event, topicindex, commentindex, tabId) {
      this.$emit("replycomment", { event: event, topicindex: topicindex, commentindex: commentindex, tabId: tabId })
    },
    saveimgtolocal(imgarray,index){
      this.imgstr=[];
      _each(imgarray,(v,i)=>{
        this.imgstr.push(v.src);
      })
      window.location.href= "image://?url=" + this.imgstr + "&currentIndex=" + index;
    }
  }
}
</script>
<style scoped>
.commentdetail-body {
  display: flex;
  flex-direction: column;
  margin: 0 0.2rem 0.2rem 0.36rem;
  background: #fff
}

.commentdetail-text {
  font-size: 0.32rem;
  color: #333333;
  line-height: 0.42rem;
  width: 5.95rem;
  word-wrap: break-word;
  text-align: left;
  margin-top: 0.05rem;
  margin-bottom: 0.02rem;
  
}

.commenturl {
  margin-top: -0.03rem;
}

.commentimg {
  width: 2.2rem;
  height: 1.7rem;
  display: inline-block;
  margin-right: 0.2rem;
  background-color: #ccc;
}

.onecommenturl {
  margin-top: 0.1rem;
  margin-bottom: 0.1rem;
  width: 3.58rem;
  height: 2.77rem;
}

.onecommentimg {
  width: 3.58rem;
  height: 2.77rem;
  margin-bottom: 0.05rem;
}

td {
  padding: 0;
  margin: 0;
}

.displace-explain {
  font-size: 0.24rem;
  color: #494949;
  font-family: "PingFangSC Regular";
  line-height: 0.42rem;
  word-wrap: break-word;
  text-align: left;
}

.body-sep {
  /*width: 6.9rem;*/
  margin-left: 0.3rem;
  margin-right: 0.3rem;
  height: 1px;
  background-color: #E6E6E6;
}

.img-list {
  width: 2.2rem;
  height: 1.7rem;
  float: left;
  margin-right: .08rem;
  margin-top: .09rem;
}
.position-place{
  padding-top: 0.1rem;;
  color: #999999;
  font-size: 0.22rem;
}

</style>
